package com.cnap.model.strategy.schedule;

import com.cnap.model.schedule.engine.DeployPolicyConfigV2;

/**
 * 负载策略
 *
 * @author xc
 **/
public class LoadStrategyDTO extends CommonScheduleDTO {
    private String policy;
    private LoadFactor param;

    /**
     * get
     *
     * @return Policy
     */
    public String getPolicy() {
        return policy;
    }

    /**
     * set
     *
     * @param policy policy
     */
    public void setPolicy(String policy) {
        this.policy = policy;
    }

    /**
     * get
     *
     * @return Param
     */
    public LoadFactor getParam() {
        return param;
    }

    /**
     * set
     *
     * @param param param
     */
    public void setParam(LoadFactor param) {
        this.param = param;
    }

    @Override
    public DeployPolicyConfigV2 toConfigV2() {
        DeployPolicyConfigV2 configV2 = new DeployPolicyConfigV2();
        configV2.setPolicyRatio(this.getPercent());
        configV2.setPolicyParam(this.getParam().getLoadFactor());
        configV2.setPolicy(PolicyEnum.getEnNameFromChName(this.getPolicy()));
        return configV2;
    }

    private static class LoadFactor {
        private String loadFactor;

        /**
         * get
         *
         * @return LoadFactor
         */
        public String getLoadFactor() {
            return loadFactor;
        }

        /**
         * set
         *
         * @param loadFactor loadFactor
         */
        public void setLoadFactor(String loadFactor) {
            this.loadFactor = loadFactor;
        }
    }


}
